/**
 * 
 */
package examples.session.stateless;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

/**
 * @author 814168
 *
 */
public class HelloClient {

	/**
	 * @param args
	 */

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {
		/*
		 * Obtain the JNDI initial context.
		 *
		 * The initial context is a starting point for
		 * connecting to a JNDI tree. We choose our JNDI
		 * driver, the network location of the server, etc
		 * by passing in the environment properties.
		 */

		
		System.out.println("about to create initialcontext");

		Properties jndiProps = new Properties();
		jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
		"org.jnp.interfaces.NamingContextFactory");
		jndiProps.setProperty(Context.URL_PKG_PREFIXES,
		"org.jboss.naming:org.jnp.interface");
		jndiProps.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
		
		InitialContext ctx = new InitialContext(jndiProps);

		//System.out.println ("Trying to get the name of this context: " + ctx.getNameInNamespace());

		System.out.println("Got initial context ... yeah ");

		/*
		 * Get a reference to a bean instance, looked up by class name
		 */

		Hello hello = (Hello) ctx.lookup("HelloBean/remote");		
		System.out.println(hello.sayHello());
		System.out.println("Client Finished .....");

	}

}
